package com.zy.ivideo.repository;

import com.zy.ivideo.entity.AccountEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface AccountRepository extends JpaRepository<AccountEntity,Long> {
    AccountEntity findAccountEntityByUserid(Long userid);

    @Transactional
    @Modifying(clearAutomatically=true)
    @Query(value="update s_account set zfbaccount=?2 where id=?1",nativeQuery=true)
    int modifyZFB(Long id,String zfb);

    @Transactional
    @Modifying(clearAutomatically=true)
    @Query(value="update s_account set wxaccount=?2 where id=?1",nativeQuery=true)
    int modifyWX(Long id,String wx);

    @Transactional
    @Modifying(clearAutomatically=true)
    @Query(value="update s_account set accountamount=accountamount+?2 where id=?1",nativeQuery=true)
    int modifyAccountAmount(Long id,double nm);

    @Transactional
    @Modifying(clearAutomatically=true)
    @Query(value="update s_account set coinamount=coinamount+?2 where id=?1",nativeQuery=true)
    int modifyCoinAmount(Long id,double nm);
}
